package com.serkol.ams.service.impl;

import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.serkol.ams.entity.VideoLikes;
import com.serkol.ams.mapper.VideoLikesMapper;
import com.serkol.ams.service.VideoLikesService;
import org.springframework.stereotype.Service;

import java.util.List;
import java.util.function.Function;

/**
* @author pingan
* @description 针对表【video_likes】的数据库操作Service实现
* @createDate 2023-11-03 00:45:21
*/
@Service
public class VideoLikesServiceImpl extends ServiceImpl<VideoLikesMapper, VideoLikes>
    implements VideoLikesService{

    @Override
    public List<Long> findByLikes(long masterId, Long userId) {
       LambdaQueryWrapper<VideoLikes> queryWrapper=new LambdaQueryWrapper<>();
       queryWrapper.select(VideoLikes::getDetailId);
        queryWrapper.eq(VideoLikes::getMasterId,masterId).eq(VideoLikes::getUserId,userId);
        return this.listObjs(queryWrapper, new Function<Object, Long>() {
                   @Override
                   public Long apply(Object id) {
                       //进行一系列转换操作 ，最终返回我们所需要的类型V ， 这里只做简单演示。
                       return Long.valueOf(id.toString());
                   }
               }
       );
    }
}




